package com.example.springboot.home;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/")
public class HomeController {
    @GetMapping({"/", "/index"})
    public Map<String, Object> index() {
        Map<String, Object> dataMap = new HashMap<>(2);
        dataMap.put("data", "hello:" + System.currentTimeMillis());
        dataMap.put("message", "ok");
        dataMap.put("code", 200);
        return dataMap;
    }

    @GetMapping("/hello")
    public Map<String, String> hello() {
        Map<String, String> map = new HashMap<>(2);
        String uuid = UUID.randomUUID().toString().replace("-", "");
        map.put("requestId", uuid);
        map.put("timestamp", String.valueOf(System.currentTimeMillis()));
        return map;
    }
}
